
export const rand = (m,n) =>{
    return Math.ceil(Math.random() * (n-m+1)) + m-1;
}

export const randPoint = (m,n) =>{
    return  rand(m,n) * Math.random();
}

//base64图片转成文件流格式
export function base64ImgtoFile(dataurl, filename = 'file') { 
    let arr = dataurl.split(',')
    let mime = arr[0].match(/:(.*?);/)[1]
    let suffix = mime.split('/')[1]
    let bstr = atob(arr[1])
    let n = bstr.length
    let u8arr = new Uint8Array(n)
    while (n--) {
      u8arr[n] = bstr.charCodeAt(n)
    }
    return new File([u8arr], `${filename}.${suffix}`, {
      type: mime
    })
}

//cookie获取
export function getCookie() { 
    let arr = document.cookie.split('=');
    let obj = {}
    for(let i = 0;i<arr.length;i+=2){
        obj[arr[i]] = arr[i+1];
    }
    return obj;
}

//utc转
export function dajsTurn(timestamp) { 
    return dayjs.utc(timestamp).format('YYYY/MM/DD HH:mm:ss');

}

